package com.hdaccp.shuiguoD.controller;

import com.hdaccp.shuiguoD.dao.JinhuoDao;
import com.hdaccp.shuiguoD.entity.Jinhuo;
import com.hdaccp.shuiguoD.entity.Xiaoshou;
import com.hdaccp.shuiguoD.service.JinhuoService;
import com.hdaccp.shuiguoD.service.XiaoshouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/xiaoshou")
@ResponseBody
public class xiaoshouController {
    @Autowired
    private XiaoshouService xiaoshouService;
    @Autowired
    private JinhuoDao jinhuoDao;


    @RequestMapping("/addls")
    @ResponseBody
    public int addls(Xiaoshou xiaoshou){
        return xiaoshouService.addls(xiaoshou);
    }

    @RequestMapping("/query")
    @ResponseBody
    public Map<String,Object> querySearch(String xiaosname, int offset, int limit){
        Map<String,Object> map = new HashMap<>() ;
        map.put("rows",xiaoshouService.findAll(xiaosname,offset,limit)) ;
        map.put("total",xiaoshouService.findTotalCount(xiaosname)) ;
        return  map ;
    }

    @RequestMapping("/all")
    @ResponseBody
    public boolean all(String xiaoname, int offset, int limit){
        boolean isok = false;
        if (xiaoshouService.findAll(xiaoname,offset,limit).size() == 0){
            isok = true;
        }
        return  isok ;
    }
}
